{// 引入标签库 }

<tagLib name="fanwe" />

<include file="Public:header" />

<load href="__TMPL__ThemeFiles/Js/jquery.js" />

<load href="__TMPL__ThemeFiles/Js/jquery.bgiframe.js" />

<load href="__TMPL__ThemeFiles/Js/model.js" />

<load href="__TMPL__ThemeFiles/Js/area.js" />

<script src="http://ditu.google.cn/maps?file=api&amp;v=2&amp;sensor=true&amp;key={:fanweC('GOOGLE_MAP_KEY')}" type="text/javascript"></script>



<div id="main" class="main" >

<div class="content">

<div class="title">{$Think.lang.EDIT_DATA} [ <a href="{:u($module_name.'/index')}">{$Think.lang.BACK_LIST}</a> ]</div>

<div id="result" class="result none"></div>

<form method='post' id="form" name="form" action="{:u('BusinessCircle/update')}"  enctype="multipart/form-data">

<table cellpadding=0 cellspacing=0 class="dataEdit" >

<tr>

	<td class="tRight" width="120">商圈名称：</td>

	<td class="tLeft" >
		<input type="text" name="name" class="bLeft" value="{$vo.name}" id="area_name" />
	</td>

</tr>
<tr>

	<td class="tRight">所属城市：</td>

	<td class="tLeft" >
		<select name="city_id" id="city_id">
			<foreach name="city_list" item="city_list">
			<if condition="$city_list['py'] neq 'china'">
			<option value="{$city_list.id}" <if condition="$city_list['id'] eq $vo['city_id']">selected="selected"</if>>{$city_list.name}</option>
			</if>
			</foreach>
		</select>
	</td>
</tr>
<tr>

	<td class="tRight">所属商圈：</td>

	<td class="tLeft" >
		<select name="parent_id" id="parent_id">
			<option value="0">顶级商圈</option>
			<foreach name="area_list" item="area_list">
				<option <if condition="$area_list['id'] eq $vo['parent_id']">selected="selected"</if> value="{$area_list.id}">{$area_list.name}</option>
			</foreach>
		</select>
	</td>
</tr>
<tr>
	<td class="tRight">商圈定位：</td>
	<td class="tLeft" >
		经度：<input type="text" name="longitude" id="longitude" class="bLeft" style="width:100px;" value="{$vo.longitude}" />&nbsp;&nbsp;&nbsp;&nbsp;
		纬度：<input type="text" name="latitude" id="latitude" class="bLeft" style="width:100px;" value="{$vo.latitude}" />&nbsp;&nbsp;
		<input type="button" value="查询" onclick="getAreaPosition();"/>
	</td>
</tr>
<tr>
	<td class="tRight">&nbsp;</td>
	<td class="tLeft" >
		如果不设置，将通过Google地图查询自动获取(有可能不准确)
	</td>
</tr>
<tr>
	<td class="tRight">{$Think.lang.SORT}：</td>
	<td class="tLeft" >
		<input type="text" name="sort" class="bLeft" value="{$vo.sort}"/>
	</td>
</tr>
<tr>

	<td>&nbsp;</td>

	<td class="center"><div style="width:85%;margin:5px">

	<input type="hidden" value="{$vo.id}" name="id" />

	<input type="submit" value="{$Think.lang.SAVE_DATA}"  class="button small"> <input type="reset" class="button small" onclick="resetEditor()" value="{$Think.lang.RESET_DATA}" > 

	</div></td>

</tr>

</table>

</form>

</div>

</div>
<script type="text/javascript">
jQuery(function($){
	$("#city_id").change(function(){
		getAreas();
	});
	
	getAreas();
});

function getAreas()
{
    var parent_id = $("#parent_id").val();
	$("#parent_id").html("");
	var city_id = $("#city_id").val();
	$.ajax({
		url: APP+"?"+VAR_MODULE+"=BusinessCircle&"+VAR_ACTION+"=getArea&city_id="+city_id,
		cache: false,
		dataType:'json',
		success:function(data)
		{
			var html = '<option value="0">顶级商圈</option>';
			var i = 0;
			if(data.list)
			{
				var count = data.list.length;
				for(i;i < count;i++)
				{
                    if(parent_id == data.list[i].id)
                        html += '<option value="'+ data.list[i].id +'" selected="selected">'+ data.list[i].name +'</option>';
                    else
					    html += '<option value="'+ data.list[i].id +'">'+ data.list[i].name +'</option>';
				}
			}
			$("#parent_id").html(html);
		}
	});
}
</script>

